package com.example.springbootdemo.modules.user.service.impl;

import com.example.springbootdemo.modules.user.dao.UserDao;
import com.example.springbootdemo.modules.user.service.UserService;
import com.example.springbootdemo.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author: ShengXiaJia
 * @Date: 2020/2/17 16:04
 * @Description:
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Override
    public int insert(User user) {
        userMapper.insert(user);
        return user.getId();
    }

    @Autowired
    UserDao userMapper;

    @Override
    public List<User> getAll() {
        return userMapper.getAll();
    }

    @Override
    public User getById(Integer id) {
        return userMapper.getById(id);
    }

    @Override
    public int update(User user) {
        return userMapper.update(user);
    }

    @Override
    public int delete(Integer id) {
        return userMapper.delete(id);
    }

}
